import request from '@/axios'
import { SysFileDetailVo, SysFileEditQo, SysFileListVo, SysFileSearchQo } from './types'
import { BaseDeleteQo } from '@/base/api/BaseQo'
import { KeyLabelValueVo } from '@/base/api/KeyLabelValueVo'

export const sysFilePageApi = (data: SysFileSearchQo): Promise<IResponse<Array<SysFileListVo>>> => {
  return request.post({ url: '/sysFile/page.adw', data })
}

export const sysFileDetailApi = (id: number): Promise<IResponse<SysFileDetailVo>> => {
  const data = { id }
  return request.post({
    url: '/sysFile/detail.adw',
    data
  })
}

export const sysFileAddApi = (data: SysFileEditQo): Promise<IResponse<number>> => {
  return request.post({ url: '/sysFile/add.adw', data })
}

export const sysFileUpdateApi = (data: SysFileEditQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysFile/update.adw', data })
}

export const sysFileDeleteApi = (data: BaseDeleteQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysFile/delete.adw', data })
}

export const sysFileDownloadApi = (id: number): Promise<IResponse<void>> => {
  return request.downloadGet({
    url: `/sysFile/download.adw?id=${id}`,
    responseType: 'blob'
  })
}

// [[ OnflowGenerator Range (- selectFunctions -) Start ]]

export const selectSysFileFileNameListApi = (
  data: SysFileSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysFile/selectFileNameList.adw', data })
}
// [[ OnflowGenerator Range (- selectFunctions -) End ]]
